/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.etrs.formathlon.entity.infrastructure;

import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import net.etrs.formathlon.entity.formation.Session;
import net.etrs.formathlon.entity.utils.ComparableEvenThoughUnpersisted;

/**
 * Entité symbolisant une salle ou se dispensera une formation.
 * @author OPIF
 */
@Entity
public class Salle extends ComparableEvenThoughUnpersisted<Salle> {

    private static final long serialVersionUID = 1L;
    
    /**
     * Identifiant.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    /**
     * Numéro du batiment - numéro de pièce.
     */
    private String libPiece;
    
    /**
     * Nombre de place de la salle.
     */
    private int nbPlace;
    
    /**
     * Précision sur la salle, ex:amphithéâtre, cinéma, écran intéractif.
     */
    private String description;
    
    /**
     * Liste des sessions.
     */
    @OneToMany(mappedBy = "salle")
    private List<Session> listSession = new ArrayList<Session>();
    private boolean archive;

    /**
     * Constructeur par défaut.
     */
    public Salle() {
        this.nbPlace = 1;
    }

    @Override
    public Long getId() {
        return id;
    }

    /**
     * Setter de l'id.
     * @param id 
     */
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return String.format("Salle id=%d, libPiece=%s", id, libPiece);
    }

    /**
     * @return the libPiece
     */
    public String getLibPiece() {
        return libPiece;
    }

    /**
     * @param libPiece the libPiece to set
     */
    public void setLibPiece(String libPiece) {
        this.libPiece = libPiece;
    }

    /**
     * @return the nbPlace
     */
    public int getNbPlace() {
        return nbPlace;
    }

    /**
     * @param nbPlace the nbPlace to set
     */
    public void setNbPlace(int nbPlace) {
        this.nbPlace = nbPlace;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the archive
     */
    @Override
    public boolean isArchive() {
        return archive;
    }

    /**
     * @param archive the archive to set
     */
    @Override
    public void setArchive(boolean archive) {
        this.archive = archive;
    }

    /**
     * @return the listSession
     */
    public List<Session> getListSession() {
        return listSession;
    }

    /**
     * @param listSession the listSession to set
     */
    public void setListSession(List<Session> listSession) {
        this.listSession = listSession;
    }
}
